//
//  GetTime.swift
//  XMGG
//
//  Created by iDev on 7/2/17.
//  Copyright © 2017 iDev. All rights reserved.
//

import UIKit


enum TimeFormate{
    case FullTime
    case YMd
    case YMdHm
    case HYMdHm
    case HYMd
    case Hms
    case ms
    case Hm
    case Md
    case YM
    case HYM
}

func getCurrentTime()->String{
    return getTime(Formate: "YYYY-MM-dd HH:mm:ss")
}

func getCurrentTime(TimeType:TimeFormate)->String{
    var dateFormate = "YYYY-MM-dd HH:mm:ss"
    switch TimeType {
    case .FullTime: dateFormate = "YYYY-MM-dd HH:mm:ss"
    case .YMd : dateFormate = "YYYY-MM-dd"
    case .YMdHm: dateFormate = "YYYY-MM-dd HH:mm"
    case .HYMdHm: dateFormate = "YY-MM-dd HH:mm"
    case .HYMd: dateFormate = "YY-MM-dd"
    case .Hms: dateFormate = "HH:mm:ss"
    case .ms: dateFormate = "mm:ss"
    case .Hm: dateFormate = "HH:mm"
    case .Md: dateFormate = "MM-dd"
    case .YM: dateFormate = "YYYY-MM"
    case .HYM: dateFormate = "YY-MM"
    }
    return getTime(Formate: dateFormate)
}

private func getTime(Formate:String)->String{
    let orignDate = Date()
    let dateFormatter = DateFormatter()
    dateFormatter.locale = Locale.current
    dateFormatter.dateFormat = "YYYY-MM-dd HH:mm:ss"
    let date = dateFormatter.string(from: orignDate)
    return date
}
